<template>
    <!--发送记录-->
    <div class="content_panel project_modules">
        <div class="content_panel_top">
            <h3 class="panel_title">
                <span>{{$t('pageTitle.sendRecord')}}</span>
            </h3>
            <el-form ref="form" :model="form" :rules="rules" :inline="false" class="module_form">
                <el-row>
                    <el-col :span="6">
                        <el-form-item prop="applyTime" label=""><!--时间-->
                            <el-date-picker
                                style="width:100%"
                                v-model="form.registerTime"
                                type="datetimerange"
                                format="yyyy-MM-dd HH:mm:ss"
                                value-format="timestamp"
                                :editable="false"
                                range-separator="-"
                                :default-time="['00:00:00', '23:59:59']"
                                :start-placeholder="$t('common.startTime')"
                                :end-placeholder="$t('common.endTime')"></el-date-picker>
                        </el-form-item>
                    </el-col>
                    <el-col :span="4">
                        <el-form-item prop="phone" label="">
                            <el-input v-model="form.phone" :placeholder="$t('common.mobileNumber')" clearable></el-input><!--手机号码-->
                        </el-form-item>
                    </el-col>
                    <el-col v-if="autoSend" :span="4">
                        <el-form-item prop="supplier"><!--发送渠道(自动发送)-->
                            <el-select v-model="form.supplier" :placeholder="$t('common.sendChannel')" clearable style="width:100%;">
                                <!-- <el-option v-for="(type,index) in autoMessageTypeData" :key="index" :value="type" :label="type"></el-option> -->
                                <el-option :key="0" value="NX_CLOUD" label="NX_CLOUD"></el-option>
                                <el-option :key="1" value="ITEXMO" label="ITEXMO"></el-option>
                                <el-option :key="2" v-if='domain=="Candy"||domain=="Pesopop"||domain=="CatCash"' value="PAASOO" label="PAASOO"></el-option>
                                <el-option :key="2" v-if='domain=="Candy"||domain=="Pesopop"||domain=="CatCash"' value="CM" label="CM"></el-option>
                                <el-option :key="3" value="HIWAY" label="HIWAY"></el-option>
                            </el-select>
                        </el-form-item>
                    </el-col>
                    <el-col v-if="!autoSend" :span="4">
                        <el-form-item prop="sendProvider"><!--发送渠道（手动发送）-->
                            <el-select v-model="form.sendProvider" :placeholder="$t('common.sendChannel')" clearable style="width:100%;">
                                <!-- <el-option v-for="(type,index) in messageTypeData" :key="index" :value="type" :label="type"></el-option> -->
                                <el-option :key="0" value="NX_CLOUD" label="NX_CLOUD"></el-option>
                                <el-option :key="1" value="ITEXMO" label="ITEXMO"></el-option>
                                <el-option :key="2" v-if='domain=="Candy"||domain=="Pesopop"||domain=="CatCash"' value="PAASOO" label="PAASOO"></el-option>
                                <el-option :key="2" v-if='domain=="Candy"||domain=="Pesopop"||domain=="CatCash"' value="CM" label="CM"></el-option>
                                <el-option :key="3" value="HIWAY" label="HIWAY"></el-option>
                            </el-select>
                        </el-form-item>
                    </el-col>
                    <el-col v-if="autoSend" :span="4">
                        <el-form-item prop="callbackStatus"><!--状态(自动发送)-->
                            <el-select v-model="form.callbackStatus" :placeholder="$t('common.status')" clearable style="width:100%;">
                                <el-option :key="1" value="1" :label="$t('common.sendSuccess')" ></el-option>
                                <el-option :key="2" value="2" :label="$t('common.sendFaild')" ></el-option>
                                <el-option :key="0" value="0" :label="$t('common.sending')" ></el-option>
                            </el-select>
                        </el-form-item>
                    </el-col>
                    <el-col v-if="!autoSend" :span="4">
                        <el-form-item prop="sendStatus"><!--状态(手动发送)-->
                            <el-select v-model="form.sendStatus" :placeholder="$t('common.status')" clearable style="width:100%;">
                                <el-option :key="1" value="1" :label="$t('common.sendSuccess')" ></el-option>
                                <el-option :key="2" value="2" :label="$t('common.sendFaild')" ></el-option>
                                <el-option :key="0" value="0" :label="$t('common.sending')" ></el-option>
                            </el-select>
                        </el-form-item>
                    </el-col>
                    <el-col :span="6">
                        <el-button @click="search" type="primary"> {{ $t('common.search') }} </el-button>
                        <el-button @click="changeSendType" type="primary">
                            <span v-if="autoSend">{{ $t('pageTitle.sendManually') }}</span>
                            <span v-else>{{ $t('collection.autoSend') }}</span>
                        </el-button>
                    </el-col>
                </el-row>
            </el-form>
        </div>
        <div class="module_content">
            <div class="content_panel project_modules">
                <div class="table_list">
                    <el-table :data="tableData" :max-height="tableMaxHeight" style="width: 100%">
                        <el-table-column align="left" :label="$t('collection.sendTime')"><!--发送时间-->
                            <template slot-scope="scope">{{ scope.row.createTime | formatDate('yyyy-MM-dd hh:mm:ss') }}</template>
                        </el-table-column>
                        <el-table-column align="left" prop="sendType" :label="$t('common.sendType')"><!--发送类型-->
                            <template slot-scope="scope">{{ +scope.row.sendType === 0 ? $t('common.auto') : $t('common.manual')}}</template>
                        </el-table-column>
                        <el-table-column align="left" :prop="autoSend ? 'supplier' : 'sendProvider'" :label="$t('common.sendChannel')"><!--发送渠道（判断自动手动）--></el-table-column>
                        <el-table-column align="left" prop="phone" :label="$t('common.mobileNumber')"><!--手机号码--></el-table-column>
                        <el-table-column align="left" :label="$t('common.SMSContent')" prop="content" :show-overflow-tooltip="true" min-width="180"></el-table-column><!--短信内容-->
                        <el-table-column align="left" :prop="autoSend ? 'callbackStatus' : 'sendStatus'" :label="$t('common.status')"><!--状态（判断自动手动）-->
                            <template slot-scope="scope">
                                <span v-if="autoSend">{{ scope.row.callbackStatus | switchStatus }}</span>
                                <span v-else>{{ scope.row.sendStatus | switchStatus }}</span>
                            </template>
                        </el-table-column>
                    </el-table>
                </div>
                <!--分页组件-->
                <pagination @pageChange="pageChange" :page="page"><!--分页组件--></pagination>
            </div>
        </div>
    </div>
</template>

<script src="./main.js"></script>

<style lang="scss">
    [data-page=operation-smsManage-sendRecord] {
        .el-col {
            padding-left: 10px;
        }
        .el-table .cell, .el-table th > .cell {
            word-break: keep-all;
            word-wrap: break-word;
        }
        .el-tooltip__popper {
            max-width: 300px;
            word-break: break-all;
            background-color: #fff;
            box-shadow: 0px 0px 5px #ccc;
            color: #000;
        }
        .el-date-editor .el-range-separator {
            width: 35px;
        }
    }
</style>
